package svc

import (
	"day15/api/internal/config"
	"day15/api/internal/middleware"
	"day15/houserpc/house"
	"day15/rpc/user"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config    config.Config
	UserSrv   user.User
	HouseSrv  house.House
	AuthToken rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:    c,
		UserSrv:   user.NewUser(zrpc.MustNewClient(c.UserSrv)),
		HouseSrv:  house.NewHouse(zrpc.MustNewClient(c.HouseSrv)),
		AuthToken: middleware.NewAuthTokenMiddleware().Handle,
	}
}
